#include<stdio.h>
#include<string.h>                                                              
#include<unistd.h>
#include<pthread.h>
#include<fcntl.h>
#include<wait.h>
#include<sys/stat.h>
#include<errno.h>
#include<stdlib.h>
#include<sys/mman.h>

int main(int argc, char* argv[])
{
    int fd = open("./mmap.txt",O_RDWR | O_CREAT |O_TRUNC, 0644);
    char* ptr=(char*)mmap(NULL,1024,PROT_WRITE,MAP_SHARED ,fd,0);
    ftruncate(fd,1024);

    int i=0;
    while(1)
    {        
        sprintf(ptr," --------%d\n",i++);
        sleep(1);
    }
     
    return 0;

}